<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>products</title>
    </h:head>
    <h:body>
           <f:view contracts="main">
            <ui:composition template="/template.xhtml">
                <ui:define name="content" id="mycontent">
      <h:form>
            <!-- <p:commandButton value="add new product" type='button' onclick="PF('addProduct').show();"/>
            <p:dialog widgetVar="addProduct"  width="400" height="350">
                
                <ui:include src="/WEB-INF/dialogs/newProduct.xhtml"/>
                
            </p:dialog>
            -->
        
        <p:dataTable id="products" var="product"
                      paginator="true" rows="100"  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                       value="#{productCon.allProducts}">
         <p:column headerText="Product Name" sortBy="name" filterBy="name" filterMatchMode="contains"> 
             <h:outputText value="#{product.name}" /> 
                                    </p:column>
             <p:column headerText="Product Discription" sortBy="name" filterBy="name" filterMatchMode="contains"> 
                 <h:outputText value="#{product.description}" /> 
                                    </p:column>
            <p:column headerText="View Details"> 
                <p:commandButton actionListener="#{productCon.viewDetails(product)}" action="viewDetails?faces-redirect=true" value="view details"/>
                                    </p:column>
        
        </p:dataTable>
            </h:form>
                </ui:define>
            </ui:composition>
           </f:view>
    </h:body>
</html>

